package com.orange.notificationsummary.utils;

import java.lang.reflect.Method;

import android.content.Context;

public class MissedCallUtils {
	private static final String	TAG										= "MissedCallUtils";

	private static final String	METHOD_GET_ITELEPHONY					= "getITelephony";
	private static final String	METHOD_CANCEL_MISSEDCALLS_NOTIFICATION	= "cancelMissedCallsNotification";

	public static void cancelMissedCallsNotification(Context context) {
		Object tm = context.getSystemService(Context.TELEPHONY_SERVICE);
		Class c = tm.getClass();
		Method getTel = null;

		try {
			getTel = c.getDeclaredMethod(METHOD_GET_ITELEPHONY, (Class[]) null);
		} catch (Exception e) {
			LogHelper.e(TAG, "cancelMissedCallsNotification. ", e);
		}

		getTel.setAccessible(true);
		try {
			Object r = getTel.invoke(tm, null); // ITelephony
			Class rc = r.getClass();
			Method getCan = null;
			getCan = rc.getDeclaredMethod(
					METHOD_CANCEL_MISSEDCALLS_NOTIFICATION, (Class[]) null);
			Object ro = getCan.invoke(r, null);

		} catch (Exception e) {
			LogHelper.e(TAG, "cancelMissedCallsNotification. ", e);
		}
	}
}
